package com.platform.usercenter.mapper;


import com.platform.common.core.domain.entity.SysRole;
import com.platform.usercenter.dataprocessing.dto.*;
import com.platform.usercenter.domain.SysOrganizationDept;
import com.platform.usercenter.domain.SysRoleMenu;
import com.platform.usercenter.domain.SysRoleMenuValue;
import com.platform.usercenter.domain.SysUserRole;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 数据处理接口
 *
 * @author wcs
 * @date 2024-09-22
 */
@Mapper
public interface DataProcessingMapper {

    /**
     * 获取待插入组织信息
     */
    List<SysOrganizationDateDTO> getOrgList();
    /**
     * 获取待插入部门信息
     */
    List<SysOrganizationDept> getOrgDeptList();

    /**
     * 获取待插入用户/组织/部门关联表信息
     */
    List<SysOrgDeptUserDTO> getUserOrgDeptList();
    /**
     * 查询组织下全部角色
     */
    List<SysOrgRoleDTO> getOrgRoleList();
    /**
     * 查询组织下全部角色
     */
    List<SysOrgRoleDTO> getOrgAppList(@Param(value = "roleIds") Long[] roleIds);

    /**
     * 处理用户默认组织信息
     * @return
     */
    int delUserDefaultOrg();

    /**
     * 新增组织
     *
     * @param sysOrganization 组织
     * @return 结果
     */
    public int insertSysOrganization(SysOrganizationDateDTO sysOrganization);

    /**
     * 新增组织部门
     *
     * @param sysOrganizationDept 组织部门
     * @return 结果
     */
    public int insertSysOrganizationDept(SysOrganizationDept sysOrganizationDept);
    public int insertSysOrgDeptUser(SysOrgDeptUserDTO sysOrgDeptUser);


    void truncateTable(@Param("tableName") String tableName);


    int selectCountByTableName(@Param("tableName") String tableName);

    @MapKey("myKey")
    List<Map<String, Object>> selectRangeDataByTableName(@Param("tableName") String tableName, @Param("start") Integer start, @Param("end") Integer end);

    List<SysRole> selectRoleFromNewTable(@Param("roleName") String roleName, @Param("destOrgId") Long destOrgId);

    SysRole selectRoleFromOldRole(@Param("roleName") String roleName);

    int insertNewRole(SysRole sysRole);

    List<SysRoleMenu> selectRoleMenuOld(@Param("oldRoleId") Long oldRoleId);

    List<AgentMenuMappingDTO> selectAgentMenuMapping(@Param("oldMenuIds") Set<Long> oldMenuIds);

    int batchInsetNewSysRoleMenu(@Param("roleMenus") List<SysRoleMenu> roleMenus);

    List<AppScenePermissionDTO> selectAppSceneAndPermission(@Param("menuIds") Set<Long> menuIds);

    List<AgentOrgInfoDTO> selectAgentInfoMap();

    int batchInsertRoleMenuValue(@Param("savaData") List<SysRoleMenuValue> savaData);

    List<UserOrgDTO> selectUserOrg();

    List<SysRole> selectUserRole(@Param("userId") Long userId);

    int batchInsertSyUserRole(@Param("saveData") List<SysUserRole> saveData);

    int executeSql(@Param("sql") String sql);
}
